/*********************************************************
	Project:		
	File name:	Lib.h
	Description:	
	Write/Modify:	apollo
	Time:	i2c analog driver	
*********************************************************/
#define BoardEEP_ADDR			0xa0///i2c1


#define USER_DATA_ADDR          	200///180
////#define USER_DATA_ADDR1     0x50//64bytes
#define PAGE_WRITE_LENGTH 		8




/****************************************************
				FM1:
0----7  PS1         8-----15 	PS2
16--23  PS3         24----31  	PS4
32---39 PS5        	40----47   	PS6
				FM2:
48---55 PS1      	56----63 	PS2
64--71  PS3         72----79  	PS4
80---87 PS5       	88----95   	PS6
         		FM3:
96----103  	PS1     104----111 	PS2
112--119 	PS3     120----127  PS4
128---135 	PS5     36-----143  PS6

144---151 	PS OF FM1
152---159 	PS OF FM2
160---167  	PS OF FM3		

170---175  AF Threshold FM_seek_Threshold MW_Seek_Treshold

176 -193 save preset freq  176 current band  177 					180-192  freq 193 checksum

****************************************************/
#define PSSaveAddress			0
#define FM1PS_EEPaddr			144 

#define Radio_Parmeter_add		170

#define Radio_PreList_Add		176

///extern const int8u hex2bcd[100];

extern void ASP_I2CStart(void);
extern void ASP_I2CStop(void);
extern void ASP_I2COut8Bit(uchar outbyte);
extern uchar I2c2_Ack(void);
extern void I2C2Out8Bit(unsigned char outbyte);
extern void I2C2Start(void);
extern void I2C2Stop(void);
extern void I2CStart(void);
extern void I2CStop(void);
extern uchar I2COut8Bit(unsigned char outbyte);
extern uchar I2CIn8Bit(void);
extern uchar TunerI2C2In8Bit(void);
extern void I2C2Ack(void);
extern void I2C2NAck(void);
extern void I2CAck(void);
extern void I2CNAck(void);
extern void I2C_WriteByte(uchar Address,uchar sub_add,uchar Write_Data);
extern uchar IICReadOneByte(uchar Address,int8u sub_add);

extern void EepromRead(uchar address,uchar begin,uchar length,uchar *p);
///extern void EepromWrite(unsigned char address,unsigned char begin,unsigned char length,unsigned char *p);
extern uchar MaxMinChangeProtect(uchar Num,signed char ChangeVal,uchar MaxVal,uchar MinVal,uchar ProtectState);
///extern void CopyString(unsigned char @far *pStr1,unsigned char @far *pStr2);
///extern void LibMain(void);
extern uchar strlen(puchar str);
extern void strcpy(puchar to,puchar from);
extern void itoa(puchar str,uchar i);
extern uchar HexToBcd(uchar hex);	//note: hex<0x63 
extern void Hex2Str(char* str,uword hex,uchar n);
extern void Wait10us(unsigned char time);
extern void Wait1ms(unsigned char time);
extern void LibInit(void);
extern void Delay_us(void);
extern void Delay_ms(uchar ms);		/*x ms*/
extern uchar ADC_8BIT(uchar channel);
extern uword ADC_10BIT(uchar channel);
extern void I2Cm_Tx (uchar *buff,uchar nb,uchar dest_add,uchar sub_add);
extern void I2C2m_Tx (uchar *buff,uchar nb,uchar dest_add,uchar sub_add);
extern void I2Cm_Init(void);

extern void I2C2_ReadByte(uchar Address,puchar Read_Data);
extern void I2C_ReadByte(uchar Address,puchar Read_Data);
#if TUNER_CHIP==TUNER_CHIP_LV25212
extern void I2Cm_TxData (char i2c_data);
extern uchar I2Cm_RxData (uchar Ack);
#endif
#if TUNER_CHIP==TUNER_CHIP_TEF6621
extern void I2C2_WriteString(uchar chip_addr, uchar *buffer,uchar Number);
extern void I2C2_ReadString(uchar chip_addr, uchar *buffer, uchar Number);
#endif
#ifndef D_STM8_INNEREEPROM
extern bool SaveSettingEeprom(puchar pSettingRAM,uchar nb,uchar word_addr);
extern bool LoadFromEeprom(puchar pSettingRAM,uchar nb,uchar word_addr);
#endif
/*********************************************************
				File End
*********************************************************/

